home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / XSD.TXT < prev    next >
Text File  |  1995-01-14  |  54KB  |  1,138 lines

  1. XSD  XGE SOUND DEVICE
  2. "Raw" sound services
  3.  
  4. Whew! This was the hardest part of all, my target was (and is) to provide
  5. "basic sound services" to implement digital sound effects
  6. and decent playback of MIDI and/or MOD files.
  7. To do this i had to "think in advance" about what i want NOW from a
  8. decent sound system and what i MAY NEED in the future
  9. (Heck! A sinestetic interface needs full-power sound support just to
  10.  look decent).
  11.  
  12. I've included some "overkilling" features like "syncronized" playback
  13. and delayed play, i think i won't use 'em for at least a year
  14. (until i implement holographic/3Dbinaural sound or other nice things).
  15.  
  16. In this release midi/mod music playback support IS NOT INCLUDED
  17. (it takes too much time to devenlop a "do it all" music driver)
  18. (not to mention all the different MOD file "extensions"
  19.  and the problem i had with finding midi instruments sample/patches)
  20. I just wanted to give you an "unified model" to help you
  21. make "portable" SOUND DRIVERS you can recycle from a game to another
  22. and distribuite around, so more games will support to the max. your soundcard.
  23. Music support "above" or "side by side" the sound drivers is up to you
  24. (not very hard, if you just want a "basic" MOD player you can do it in
  25. just a week).
  26.  
  27. Another thing not included is support for 16bit sound output.
  28. I've included comments & descriptions about how to make a 16bit driver
  29. but the current 386mixer module DOES NOT SUPPORT 16bit sound
  30. (currently i don't have a 16bit sound card available for testing)
  31.  
  32. Eh! If you want to make a cool game with lots of graphics and sounds
  33. and want to make it run with 4Mbyte of ram .... 8bit is good enough
  34. and uses half the memory of equivalent 16bit samples.
  35. In the next MAJOR release (386P 3.00) there will be complete 16bit support
  36. into 386mixer, plus lots of other goodies.
  37.  
  38. ------------------------------------------------------------------------------
  39.  
  40. Well, sound on a pc compatibles is the part i'm less skilled at all.
  41. I bought a sound card last summer, and started making experiments with it
  42. but i'm not an expert.
  43. Another problem is that sound hardware is the less standardized thing on PCs
  44. and sometimes needs a complex setup and trimming.
  45.  
  46. By the way, given the current trends i plan to "standardize"
  47. on MOD files for music sources (and later MIDI, because is a lot harder
  48. to support and a lot less flexible)
  49. and on a "wavetable mixer sound system" for digital sound
  50. that's easy to implement on the current sound hardware.
  51.  
  52. By the way, if you still haven't one, go get a sound card
  53. at least a cheap SoundBlaster Pro compatible  (HARDWARE COMPATIBLE!!!!!!
  54. Not a thing with software emulation!!!!!).
  55. If you don't want to, .... well you are stuck with the beeper buzzs & clicks
  56. plus higher cpu overhead.
  57.  
  58. ------------------------------------------------------------------------------
  59.  
  60. What's an XSD driver?
  61.  
  62. An XSD driver is a software module
  63. that interfaces you program to any hardware device (or software module)
  64. capable to play sound.
  65.  
  66. There are basically TWO "sound output" models supported by XSD drivers :
  67.  
  68.        XSDACD   XGE Sound DAC Device
  69.                 A DAC device for sound output (with or without DMA support)
  70.                 with software simulated multiple voices
  71.  
  72.        XSWAVD   XGE Sound WAVetable  Device
  73.                 A multiple wavetable device with on-board ram
  74.  
  75. An XSDACD hardware supports playback of ONE digital sound sample
  76. at a fixed sample rate, without "effects".
  77. It can be the any kind of DAC, from the 1bit "dac equivalent" pc-speaker output
  78. to an 8bit sound dac plugged into the printer port
  79. (Example: Disney SoundSource, SoundPlayer, Covox kits etc. etc.)
  80. to a 8/16bit dac included into a "real" sound card
  81. (Examples: SoundBlaster, Pro Audio Spectrum, etc. etc.)
  82.  
  83.  
  84. An XSWAVD is a sound card with internal ram and
  85. "multiple wavetable output hardware"
  86. it can play multiple sounds and manipulate 'em with OPTIONAL effects
  87. (Examples: Gravis UltraSound,SoundBlaster AWE32, Ensoniq boards, etc. etc.)
  88.  
  89. HOW AN XSD DRIVER IS INSTALLED:
  90.  
  91. You don't access thge driver directly, you use an higher level module
  92. called 386mixer that "smooths out" differences between different sound hardware
  93. and gives you the illusion to always have a multi-voice wavetable system.
  94.  
  95. When 386mixer initializes it checks in order for:
  96.         1) the external default sound driver module  XSD.XSD
  97.         2) if XSD.XSD is not present, 386mixer
  98.            "activates" a built-in driver if sound output is on
  99.            [ usually you should let the user choose between
  100.              one of these drivers:
  101.                 a) "null" driver (no sound)
  102.                 b) pc-speaker driver
  103.                 c) 8bit SoundBlaster driver
  104.            ]
  105.  
  106. The XSD driver gets "connected" to the 386MIXER interface module.
  107. 386MIXER "unifies" support for multi channel digital sound
  108. thru dac and wavetables devices (see the 386mixer.inc file).
  109.  
  110. An XSWAVD driver MUST include support for XDACW
  111. (this way it is possible to "overflow" the wavetable ram
  112.  and store wavetables in excess into system ram).
  113.  
  114. If XSWAVD is not present it can be emulated on the XSDACD by 386mixer
  115. (remember that at least the pc-speaker is present)
  116. but this will produce additional cpu work.
  117. Because of this "emulation overhead", 386mixer includes options for
  118. partially disabling "wavetable sound".
  119.  
  120. Here follows the description of the XSD interface, but
  121. i suggest you to read rm_sound.xt first because some terms described there
  122. are not explained here.
  123.  
  124. XSD DAC INTERFACE: Knee deep in the DAC :)
  125.  
  126. If just a DAC is present (even the PC-SPEAKER can be seen as a 1bit DAC
  127. controlled with sort of pulse width modulation) this baby is capable to
  128. simulate a multi-voice sound system "mixing on the flight" the sound data.
  129.  
  130. In practice, a "simple" multi-voice wavetable device is simulated by software
  131. routines (hoping your cpu is powerful enough) so you don't see the "raw" dac
  132. and you can think you have a decent sound hardware available.
  133.  
  134. Instead of mixing sounds every time a new sample has to be played, the mixer
  135. mixes "a block" of samples and then sends the block to the actual sound
  136. hardware.
  137.  
  138. This way we can simulate multiple voices (softchannels)
  139. on a single dac port (hardchannel)
  140. AND still take advantage of the DMA support most sound cards have.
  141.  
  142. Even if the sound card has no DMA, the "block" mixing helps
  143. reduce the mixing overhead (you reduce the load/store of pointers
  144. needed to reference the sound samples to mix).
  145.  
  146. DAC FEEDBACK RATE:
  147. When you "play" a sound it actually starts at the next
  148. "mix block" interval, so, to avoid "decoupling" problems
  149. between sound and video you can control the DAC FEEDBACK RATE
  150. (the frequency the "mix sound" routine is called and thus
  151.  the "play sound --> hear sound" feedback frequency you get).
  152.  
  153. When you set the DAC FEEDBACK RATE, the 386mixer system just calculates
  154. how big must be the "mixage block" it sends to the sound hardware
  155. to have the sound hardware "call for reload" the mixage system
  156. at the requested rate.
  157.  
  158. DAC PLAYBACK RATE:
  159. The playback rate is the frequency you send your sound samples to the DAC.
  160.  
  161. PRACTICAL LIMITS ON PLAYBACK AND FEEDBACK RATES:
  162.  
  163. Usually, the higher the playback rate, the better sound quality you get
  164. but more memory is needed to store sound samples, and more time is spend by
  165. the cpu to mix samples.
  166.  
  167. The feedback frequency has not to be too high
  168. (or you'll loose the speed advandaces of "block mixing" and you will add
  169.  too much noise because of the possible "sound gaps" between a sound block
  170.  and the next) nor too low (or you'll "decouple" sounds from animation).
  171.  
  172. The mixing itself can be a cpu intensive thing if you play sounds
  173. at high playback rates or in 16bit stereo.
  174. Remember to include into you program a way to control the capabilities
  175. of the sound systems (i.e. so if 44Khz, 16bit stereo sound slows down the game
  176. or uses too much memory, the user can set the system to 8bit 8Khz mono sound).
  177. Remember to include an EXTERNAL setup program to take care of settings
  178. that may hang your main program.
  179.  
  180. AUTOROTATION:
  181.  
  182. When you play a sound, you can use a specific softchannel
  183. or tell the mixer to "autorotate" (choose a channel not playing OR
  184. the channel that is playing the same sound for the longest time).
  185.  
  186. Using autorotation you can have impressive multi-voice sound
  187. with very few channels, but sometimes you want to exclude some channels
  188. from autorotation (i.e. if you want to use a channel to play the soundtrack
  189. you don't want a new sound to autorotate on it).
  190. To keep care of this there are options in the initialization routine.
  191.  
  192. THE FEEDERS:
  193.  
  194. This "DAC software mixer" looks very weak, isn't it?
  195. Well, you can EXTEND IT !!! Let's lee how....
  196. Question: What happens when a sample on a softchannel is completed ?
  197. Answer:   The softchannel FEEDER routine gets called.
  198.  
  199. Every softchannels has a "feeder", when the currently
  200. playing sound is completed, the softchannels' feeder routine is called
  201. and it must "feed" the next sample to play to the mixage system.
  202.  
  203. Usually when a sound ends playing on a channel, that channel is set
  204. to a "silence" soundtrack, but you can specify what sound to repeat
  205. on sound termination (this way you can add "background sounds"
  206. when no specific sounds have to be played).
  207. This "reloading" is performed by the default "feeder" routine, if you change
  208. the feeder you can do more complex things (like "composing" sound and envelopes
  209. on the flight).
  210.  
  211. 386Mixer includes "extended feeders"
  212. and other support code to let you emulate on softchannels
  213. the capabilities of a "super" wavetable device:
  214. - volume control
  215. - volume ramps
  216. - panning control
  217. - panning ramps
  218. - playback rate control
  219. - playback rate ramps
  220. - delayed playback
  221. - synchronized playback
  222.  
  223. If all this is not enough, you can hook to every softchannel
  224. a "custom" feeder to add other capabilities or to override the default
  225. capabilities.
  226. These "feeders" can be allocated indipendently channel-by-channel
  227. so you can minimize the sound processing overhead.
  228.  
  229. MASTER VOLUME CONTROL:
  230.  
  231. The XSDACD driver can provide "MASTER" SOUND VOLUME control, if it does
  232. the mixer will use the fastest mixage-routine it has and will leave the
  233. sound output volume control to the driver.
  234. If no master volume control is available (argh!) the mixer will use
  235. a slower routine that supports software volume control.
  236.  
  237. If you don't want sound volume control (i.e. because your speakers have
  238. volume controls) you can disable it.
  239.  
  240. XSD WAVETABLE INTERFACE:
  241.  
  242. The XSWAVD device supports all the functions provided by XSDACD devices
  243. plus extra capabilities.
  244.  
  245. These capabilities usually include AT LEAST:
  246. - hardware mixing of multiple "voices"
  247. - storing of sound samples into "on board" soundcard ram
  248. - hardware support for volume control and panning control.
  249.  
  250. Practically speaking, if you have a wavetable based sound card
  251. you can "move to hardware" lots of functions
  252. that using an XSDACD you'd have to perform with software emulation
  253. and "feeders".
  254.  
  255. I call "wavechannels" the "hardware enhanced" softchannels
  256. (even if when you play sounds on 386mixer you don't see the difference
  257. if you don't need to)
  258.  
  259. As i said before, an XSWAVD includes support for XSDACD too
  260. the reason for this is that only samples stored into "on board" soundcard ram
  261. can take advantage of wavetable hardware support.
  262. If there is not enough ram into the soundcard it is still possible to
  263. load and play other samples loaded into system ram.
  264.  
  265. When you want to play a sound, the mixer can detect
  266. where the actual sound data is and use the appropriate channel
  267. (softchannel or wavechannel).
  268. The "virtualized" mixer sound channels are called soundchannels
  269. they will be implemented on softchannels or on wavechannels depending
  270. on where the digital sound data is stored.
  271.  
  272. Sounds can be on wavetable ram and on system ram
  273. (but a single sound must be either totally into system ram
  274.  or into wavetable ram, not splitted between them).
  275.  
  276. Because of this, you MUST have as many
  277. "not autorotating" softchannels
  278. as the "not autorotating" wavechannels.
  279.  
  280. When you exclude from autorotation wavetable sound channel N
  281. you exclude "wavetable emulating" softchannel N  AND wavechannel N
  282. (so you can play a Sound on channel N indipendently from where it resides).
  283. You can have more "autorotating" wavechannels than softchannel-emulated ones
  284. but the "not rotating" ones must be in the same number.
  285.  
  286. The reverse applies to softchannels.
  287.  
  288. This is hidden by the 386mixer module
  289. (when you say "play wavetable sound on channel N"
  290.  it will be the mixer that will select the correct sound channel
  291.  either a real one or an emulated one).
  292.  
  293. If you want N "not autorotating" soundchannels
  294. the mixer will set up N "not autorotating" softchannels
  295. and N "not autorotating" wavechannels.
  296. 386mixer will choose the correct softchannel or wavechannel to use.
  297. Of course, you can always "limit" the system an tell it to
  298. "not emulate" if you can put everything into soundcard ram.
  299.  
  300. REAL OVERKILL:
  301. There are three "capabilities" that look like they are overkill
  302. for a "basic" sound system:
  303. - playback rate ramps
  304.         These are useful to simulate the "doppler effect" sound distortion
  305.         caused by ACCELERATING/DECELERATING sound sources.
  306.         ( If for example an airplane runs to you, then decelerates
  307.           turns around you and then runs away, you will hear
  308.           the "swhoosh" caused by the jet engine changing frequency
  309.           in a rate ramp, a constant rate level (together with a panning ramp)
  310.           and a final rate ramp).
  311.         I don't even know if i will really want to implement such things
  312.         but i may decide to do so, and because of this 386mixer
  313.         has the "hooks" needed to implement it.
  314.  
  315. - delayed playback
  316.         This is useful to simulate echo effects (together with
  317.         panning and volume control), and provide "hooks" for
  318.         3dbinaural sound.
  319.  
  320. - synchronized playback
  321.         This is useful to take care of sound system's limitations
  322.         when playing on XSDACW and wanting a group of sounds starting
  323.         together.
  324.         You can do the same turning off and on irqs, but this way
  325.         it is possible to minimize system overhead.
  326.  
  327. THE GOOD THE BAD AND THE UGLY, how to speed up things.
  328.  
  329. The golden rule is: The lower the playback rate, the faster you mix
  330. (less samples to process) but this also means the worse the sound.
  331. If you don't want to walk this way, you can try ....
  332.  
  333. If you just make not-3d games, use a "simple" DAC model
  334. (it has the least cpu overhead) an use a stripped down music system with no
  335. support for volume, panning and variable playback rate ramps.
  336.  
  337. Faster "DAC sound":
  338. To further speed-up sound generation it is possible to cut other corners.
  339. Because softchannels are mixed in 4 channels groups when "no effects"
  340. are used, if you use 4 or less softchannels
  341. the mixer can reduce the sound resolution (8 to 6 bits or 16 to 12 bits)
  342. to be sure no sample overflows can happen and get a faster mixing.
  343.  
  344. If you choose not to use "software emulated" master sound volume control
  345. you can get another little speed gain.
  346.  
  347. Faster WAVETABLE EMULATION:
  348. Volume ramping and pan ramping adds TWO steps to wavetable emulation
  349. playback ramping adds another.
  350. Removing panning and freq.ramping you can reduce sound manipulation overhead.
  351. These "ramping" effects are only needed if you want to include support
  352. full support for MOD/MIDI files playback or if you want "sound motion" effects.
  353. [ using both volume and pan ramps you can produces "sound distortion"
  354.   caused by sound sources ACCELERATING/DECELERATING AT HIGH SPEED
  355.   while using volume ramps and panning control you can produce effects
  356.   equivalent to MOVING sound sources]
  357.  
  358. Volume control and panning control can be eliminated if you don't need
  359. "sound source 2D positioning".
  360.  
  361. Playback rate control can be eliminated if you don't need
  362. doppler effects at all and don't play MOD/MIDI files.
  363.  
  364. ALL THESE OPTIMIZATIONS CAN BE DONE "CHANNEL BY CHANNEL"
  365. with different settings for every channel and ONE COMMON SETTING
  366. for all the autorotating sound channels.
  367.  
  368. Faster sound playback on MULTIPLE WAVETABLE HARDWARE:
  369. By turning on some flags in the 386mixer configuration menu, you can
  370. tell the system to store everything into wavetable ram, so no system
  371. ram will be used to store sound samples and no emulation at all will happen.
  372.  
  373.  
  374. Now, let's see the sound system capabilities
  375. depending on the available hardware:
  376.  
  377. HARDWARE:          DAC:  WAVETABLE:  WAVETABLE EFFECTS:          SPEED:
  378. MONO   DAC         yes   emulated    volume and looping          medium
  379. STEREO DAC         yes   emulated    volume,panning and looping  slow
  380. MONO   WAVETABLE   yes   yes         volume and looping          fast
  381. STEREO WAVETABLE   yes   yes         volume,looping and panning  fast
  382.  
  383. & now, the mixer ....
  384.  
  385. -------------------------------------------------------------------------------
  386. THE COMPLETE 386MIXER INTERFACE
  387.  
  388. _MixInit:       Initializes sound system
  389.  
  390.                 in: All the "user defined" entries into the _XSDTable
  391.                     must be set to tell the mixer what you exactly want
  392.  
  393.                 out: The _XSDTable entries
  394.                      modified to the nearest values
  395.                      the current driver can support
  396.                      Setting impossible values (i.e -1) into parameters
  397.                      the mixer system responds setting itself
  398.                      to the "default" status.
  399.  
  400.                 The "dac mixer feedback frequency" is the frequency
  401.                 the ac mixer system "feeds" a new mixed sound data block
  402.                 to the dac hardware.
  403.                 Given the current 4k block limit, the lowest "feed"
  404.                 frequencies can be:
  405.                 Frequency      8bit   16bit/8bit_stereo  16bit_stereo
  406.                    8000         2Hz     4Hz               8Hz
  407.                   11000         3Hz     6Hz              12Hz
  408.                   22000         6Hz    12Hz              24Hz
  409.                   44100        11Hz    22Hz              44Hz
  410.  
  411.                 For maximum "animation/sound feedback" it is better to
  412.                 choose a 30..45Hz feedback frequency, or a feedback
  413.                 frequency twice the frame rate if the frame rate
  414.                 is under 20 FPS.
  415.  
  416.                 DAC "soft channels" and Wavetable "wave channels"
  417.                 are numbered starting from 0, but if wavetable hardware
  418.                 is present it must reserve one or two wavechannels
  419.                 to simulate the DAC hardchannel.
  420.  
  421. HOW _MixInit WORKS:
  422.         First of all it tries to load&init
  423.         XSD.XSD
  424.         the "not supported" entries are set to the default emulation code.
  425.  
  426.         The config data and environment var is then read and a pointer to it
  427.         is set into the device table.
  428.  
  429.         Then the check routine is called
  430.         _XSD_CHECK (sound hardware check)
  431.         It must return carry clear if successful.
  432.  
  433.         Then _XSD_INIT is called.
  434.         Once this is completed, the config file is rewritten
  435.         with the current settings
  436.         (settings can be modified by the check or the init routine).
  437.  
  438.         At last _XSD_ON is called and the sound system is ready to go.
  439.                 N.B. The config files contains the "old" iobase/irq/dma
  440.                      settings plus the volume settings and other things.
  441.  
  442.  
  443. ; XSD DRIVER TABLE
  444. ; - All entries marked with [*] means the user/program
  445. ;   can set 'em as it want, but the driver will correct 'em to the nearest
  446. ;   supported value.
  447. ;
  448. ; - All entries marked with [@] means their meaning can be different
  449. ;   if a wavetable driver is present (example: if a field contains
  450. ;   a pointer to a system ram location when a "dac" device is used,
  451. ;   when a "wavetable" is used it could be a pointer to  soundcard ram).
  452. ; - All entries marked with [W] are "wavetable specific" fields
  453. ;   the wavetable driver can use for storing internal values
  454. ;   "the name of the entry" is just indicative, the XSWAVD driver
  455. ;   can use it for anything it want!!!!
  456. ; - All entries marked with [C] means that a "custom routine" may change
  457. ;   the meaning of the entry.
  458. ;
  459. ; - Field sizes:  [D] = dword, [W] = word, [B] =byte.
  460.  
  461.         align byte
  462. _XSDTable     dd 0 ; dummy field internally used by the XSD driver.
  463.                    ; the XSD driver code receives a pointer to _XSDTable
  464.                    ; and thru it can reference all the variables
  465.                    ; following it....
  466.  
  467. _XSD_DRVTYPE  dd 0 ; XSD driver capabilities, flags set by the XSD driver
  468. ; these flags are set by the xsd driver to tell 386mixer
  469. ; what the hardware can do
  470.  
  471. xsd_dacvol=1     ; set= device supports "master" volume control
  472. ; the following flags describes the XSWAVD capabilities
  473. ; (available only if xsd_wavedriver is set)
  474. xsd_volctrl=2   ; set= device supports VOLUME control
  475. xsd_panctrl=4   ; set= device supports PANNING control
  476. xsd_ratectrl=8  ; set=  device supports
  477. xsd_volramp=16  ; set= device supports VOL. RAMPS
  478. xsd_panramp=32  ; set= device supports PAN. RAMPS
  479. xsd_rateramp=64 ; set= device supports playback rate ramps
  480. ; specific driver capabilities
  481. xsd_stereo=128    ; set= stereo sound output
  482. xsd_16bit=256     ; set= 16bit SAM sound output (16bit integer samples)
  483.                   ; else 8bit PCM sound output (8bit unsigned samples)
  484.                   ; CURRENTLY ONLY 8bit PCM is supported
  485.                   ; 16bit will be included in 386P 3.00
  486. xsd_wavedriver=512; set= device is a multiple wavetable device
  487.                   ;      (and XSWAVD device)
  488.                   ;      else it is a DAC device
  489.  
  490. _XSD_MIXTYPE dd 0 ; 386mixer capabilities
  491. ; list of flags for _XSD_SETTINGS and their names
  492. ; these flags lets you fine tune the mixer capabilities
  493. ;
  494. ; emulation control flags, these are global flags you can use
  495. ; at startup to globally turn or or inhibit some emulation capabilities
  496. ; (i.e. if you want volume ramping on a channel
  497. ;       and volume ramping is globally disabled
  498. ;       that channel won't be set for volume ramping)
  499. ; THESE ARE IGNORED IF THE CAPABILITY IS PERFORMED BY HARDWARE
  500. mix_dacvol=1     ; set= software master volume control
  501. mix_volcrtl=2    ; set= software volume control
  502. mix_pancrtl=4    ; set= software panning control
  503. mix_ratectrl=8   ; set= software playback rate control
  504. mix_volramps=16  ; set= software volume ramping on
  505. mix_panramps=32  ; set= software pan ramping on
  506. mix_rateramps=64 ; set= software playback rate ramping on
  507. ; sample conversion/mapping/allocation flags
  508. mix_cut=128       ; set= mixer performs "cutted" sample mixing
  509.                   ; (this speeds up things a lot when emulating
  510.                   ;  multiple voice systems)
  511. mix_soundout=256  ; set= if soundcard has internal ram
  512.                   ;      STORE EVERY SAMPLE into soundcard
  513.                   ;      AND EXIT THIS PROGRAM IF THERE IS NOT ENOUGH
  514.                   ;      SOUNDCARD RAM
  515. mix_soundin=512   ; set= STORE EVERY SAMPLE into system ram
  516.                   ;      (useful to test drivers in "all emulated" mode
  517.                   ;       or to disable faulty functions on a
  518.                   ;       not-so-well coded driver)
  519.                   ; THIS FLAG OVERRIDES mix_soundout !!!!!!
  520. mix_interpolate=1024 ; set= the final "mixed" sound sample
  521.                      ;      on emulated soundchannels gets smoothed
  522.                      ;      and played AT TWICE the sampling frequency
  523.                      ;      to eliminate noise
  524.  
  525. _XSD_MIXMENU  dd 0 ; pointer to mixer-control menu
  526.                    ; ("generic" configuration menu
  527.                    ;  it includes cosmetic options that are not essential
  528.                    ;  to set AND it includes _XSD_DRVMENU menu as a submenu)
  529. _XSD_DRVMENU  dd 0 ; pointer to device-control menu
  530.                    ; (call this if you need user-driven
  531.                    ;  basic mixer/driver configuration)
  532.                    ; (it includes the XSD driver menu as a submenu)
  533.  
  534. ; sound hardware settings, save these on the config file
  535. ; and then reload 'em from it
  536. _XSD_Base dd 0 ; [*] i/o address of device
  537. _XSD_IRQ  dd 0 ; [*] irq used by the sound system
  538.                ;     IF SET To ZERO, the 386mixer must use
  539.                ;     the _XSD
  540. _XSD_DMA  dd 0 ; [*] dma channel 0..3 == 8bit ISA dma, 4..7 == 16bit ISA dma
  541.  
  542. ; sound configuration by "ENVIRONMENT STRING"
  543. _XSDEnvValue   dd 0 ; pointer to the ASCIIZ value of the environment var
  544.                     ; named like _XSDEnvVar
  545.                     ; (set by 386mixer)
  546.                     ; NULL == use _XSD_Base,_XSD_IRQ,_XSD_DMA settings
  547.  
  548. ; The SoftChnnelizer: MAIN SOFTCHANNEL EMULATOR
  549. ; Call this from the irq driver to perform softchannel-emulation.
  550. ; The called routine will return INTO ESI the PHYSICAL address of the resulting
  551. ; block to send to the hardchannel, the equivalent CODE32 RELATIVE offset
  552. ; will be returned into EDI.
  553. ; You can trust the physical address is "dma reachable".
  554. _XSD_SOFTCHANNELIZER dd 0 ; Well, that's what it does! :)
  555.  
  556. ; freeze/unfreeze data
  557. _XSD_SYNC   dd 0 ; "atomic access" flag , this "freezes" the internal status
  558.                  ; of the mixer system, preventing IRQs to modify it.
  559.                  ; IRQs can set the _XSD_SYNCMIX entry to their
  560.                  ; "delayed update" routine to take care of this.
  561.  
  562. _XSD_SYNCMIX dd 0 ; routine to call when _MixUnSyncSound is called.
  563.  
  564. ; DMA block addresses (the first is the block currently playing on the dac)
  565. ; (the second is the block "under mixage" (will be sent when the
  566. ; currently playing block ends)
  567. ; their size can range between 4k to 8k
  568. ; A call to _XSD_SOFTCHANNELIZER will "swap" 'em as a side effect
  569.  
  570. ; DAC DMA DATA
  571. _XSDBlock1  dd 0 ; code32   address of first data block buffer
  572. _XSDPhys1   dd 0 ; physical address  "  "    "     "     "
  573.  
  574. _XSDBlock2  dd 0 ; ditto for second data block buffer
  575. _XSDPhys2   dd 0 ;
  576. _XSDBaseDriver dd 0 ; base offset where the XSD driver is loaded
  577.  
  578. ; START OF "copied" driver header
  579. ; Here follows the "relocated" XSD driver table
  580. ; (see xsdrv.txt for specific info about the XSD driver format)
  581.  
  582. _XSDSignature dd 0   ; there must be four bytes as follows:
  583.                      ; db 'XSD',0
  584.                      ; This means XSD revision ZERO driver
  585.                      ; has been found and loaded
  586.  
  587. _XSDInit      dd 0   ; pointer to the
  588.                      ; "hardware check" and system initialization code
  589.                      ; it will also initialize all data structures needed
  590.                      ; by the driver.
  591.                      ; IN: ebp=driver base offset (code32 relative)
  592.                      ;         (use this to fix-up addresses)
  593.                      ;     edi=XSD device table
  594.                      ;         (code 32 relative offset
  595.                      ;          of _XSDTable, from it you know
  596.                      ;          where the other "XSD variables" are
  597.                      ;          and where the sound channel descriptors are)
  598.                      ; OUT:
  599.                      ;     If carry clear then OK
  600.                      ;     else
  601.                      ;         EAX=error code
  602.                      ;                  0 = device not recognized
  603.                      ;                  1 = not enough memory
  604.                      ;                  2 = XSD device table contains
  605.                      ;                      wrong values
  606.  
  607. _XSDSetup  dd 0      ; pointer to the
  608.                      ; sound system setup routine
  609.                      ; Simply set properly the values into the
  610.                      ; XSD device table (playback frequency, feed frequency
  611.                      ; active channels, types of emulation
  612.                      ; etc.etc.)
  613.                      ; and then call this.
  614.                      ; IN: none
  615.                      : OUT: XSD table set to the NEAREST supported values.
  616.                      ;      all channels "preset" to silence.
  617.  
  618. _XSDON dd 0          ; pointer to routine that
  619.                      ; turns on sound system (setting up IRQ handlers
  620.                      ; locking DMA channels, starting up transferts
  621.                      ; AND turning ON sound output).
  622.                      ; THIS ROUTINE will at least "set up" an IRQ handler
  623.                      ; to handle "end of DMA" from soundcard
  624.                      ; and calls to the _SOFTCHANNELIZER
  625.                      ; "mixer emulation" routine.
  626.  
  627. _XSDOFF dd 0         ; pointer to routine that
  628.                      ; turns off sound system (turns off sound output
  629.                      ; disables DMA, unlocks DMA channel, restore IRQ handlers)
  630.  
  631. ; the following entries may be not supported, it will be up to
  632. ; _XSDInit to set correctly the flags into _XSD_DRVTYPE (into XSD device table)
  633. ; to tell 386mixer what is supported and what's not
  634.  
  635. _XSDMVol dd 0        ; pointer to
  636.                      ; MASTER VOLUME CONTROL routine
  637.                      ; this affects the output volume of all active channels
  638.                      ;
  639.                      ; actual_channel_volume = (chan_volume/255)*master_volume
  640.                      ;
  641.                      ; IN: al=channel volume (0..255)
  642.                      ;        0   = sound off
  643.                      ;        255 = maximum output
  644.                      ;
  645.                      ; The master volume can have a coarser granularity
  646.                      ; than sound channel volume
  647.                      ; (i.e. on a sound blaster Pro, master volume can range
  648.                      ;       between 0..15 if you just use "output volume"
  649.                      ;       but if you split master volume with
  650.                      ;       the lower four bits controlling
  651.                      ;                          "voice volume" (0..15)
  652.                      ;       and the higher four bits controlling
  653.                      ;                          "output volume" (0..15)
  654.                      ;       you can get the "complete" 0..255 range.
  655.  
  656. ; these entries are specific of "wavetable" soundcards
  657. ; (flag xsd_wavedriver set)
  658.  
  659. _XSDPlay dd 0        ;  pointer to routine that
  660.                      ; plays a sound sample
  661.                      ; IN: esi= ptr to the sound channel descriptor
  662.                      ;          describing what to play and HOW to play it
  663.  
  664. _XSDVol dd 0         ;  pointer to routine that
  665.                      ; sets volume level/ramp only
  666.                      ; IN: esi= ptr to the sound channel descriptor
  667.                      ;          describing what to play and HOW to play it
  668.  
  669. _XSDPan dd 0         ;  pointer to routine that
  670.                      ; sets panning level/ramp only
  671.                      ; IN: esi= ptr to the sound channel descriptor
  672.                      ;          describing what to play and HOW to play it
  673.  
  674. _XSDRate dd 0        ;  pointer to routine that
  675.                      ; sets playback rate ratio (relative to playback freq)
  676.                      ; level/ramp only
  677.                      ; IN: esi= ptr to the sound channel descriptor
  678.                      ;          describing what to play and HOW to play it
  679.  
  680. _XSDEnvVar dd 0      ;  pointer to ASCIIZ string
  681.                      ; with the name of the MS-DOS ENVIROMENT VAR
  682.                      ; to check for config info
  683.                      ;(for a sound blaster it is "BLASTER",0 )
  684.  
  685. _XSDMenu dd 0        ;  pointer to
  686.                      ; User driven "driver setup" menu for custom configuration
  687.                      ; ("executing" this menu results in interactive calls to
  688.                      ;   _XSDSetup subroutines)
  689.  
  690. _XSDCardType dd 0    ;  pointer to ASCIIZ string
  691.                      ; max. 30 character long
  692.                      ; (use this in the "choose driver" list)
  693.  
  694. _XSDProgrammer dd 0  ;  pointer to ASCIIZ string
  695.                      ; with multiple lines of text,max. 40 char each
  696.                      ; (use the LF char (code 10h) to mark newlines)
  697.                      ; (extended info on driver)
  698.  
  699. _XSDNotes dd 0       ;  pointer to ASCIIZ string
  700.                      ; with multiple lines of text,max. 40 char each
  701.                      ; (use the LF char (code 10h) to mark newlines)
  702.                      ; of notes about the driver usage and supperted display
  703.                      ; cards.  (detailed info)
  704.  
  705. _XSDWClear dd 0      ;  pointer to routine that
  706.                      ; "resets" wavetable ram to "all free"
  707.  
  708. _XSDWMark dd 0       ;  pointer to routine that
  709.                      ; "marks" currently used wavetable ram
  710.                      ; OUT: eax= mark handle
  711.  
  712. _XSDWRelease dd 0    ;  pointer to routine that
  713.                      ; releases wavetable ram from the higher "currently in use"
  714.                      ; location down to the "marked" position
  715.                      ; IN: eax= mark handle that will be the new
  716.                      ;          "currently in use" limit
  717.  
  718. _XSDWUpLoad dd 0     ;  pointer to routine that
  719.                      ; "loads" into wavetable ram a sound sample
  720.                      ; and returns info about it in "soundcard specific"
  721.                      ; units.
  722.                      ; IN: eax= sample size in dwords
  723.                      ;     edx= sample data ptr
  724.                      ; OUT:
  725.                      ;   IF carry clear THEN
  726.                      ;      eax= "internal" sample size count
  727.                      ;      edx= "internal" sample data ptr
  728.                      ;   ELSE
  729.                      ;       carry set, not enough wavetable ram
  730.                      ;   END-IF
  731.  
  732. _XSDTimed   dd 0     ; pointer to the "timer driven" sound support system
  733.                      ; for "sound systems" without irq support
  734.                      ; (i.e. the pc-speaker or the "dac on printer port")
  735.                      ; (similar to the irq handler used by
  736.                      ;  "soundcards with irq support", but this is just
  737.                      ;  a near routine)
  738.  
  739. ; end of "copied" driver header
  740. _XSD_BASERATE  dd 0 ; [*] basic sample rate
  741.                     ; ALL samples will be converted
  742.                     ; to this sample rate.
  743. _XSD_BRATETRANS dd 0 ; [@] rate "translation" value to use when emulating
  744.                      ;     the DAC hardchannel on a wavechannel
  745. _XSD_MVOL      dd 0 ; master volume (0..255)
  746. _XSD_MVOLTRANS dd 0 ; [@] volume "translation" value to use when using
  747.                     ;     "hardware" volume control
  748.  
  749. _XSD_FEEDRATE dd 0 ; basic feeder rate for sofchannels  [*]
  750. _XSD_FEEDSIZE dd 0 ; size of feeder block in bytes      [*]
  751. _XSD_FEEDBLCK dd 0 ; maximum size of feed blocks
  752. _XSD_CUSTOM   dd 16 dup(?) ; 64bytes available for soundcard's "private info"
  753. ; soundcard ram info
  754. _XSD_WAVFOOT   dd 0 ; start of soundcard ram         [@]
  755. _XSD_WAVBASE   dd 0 ; start of soundcard's free ram  [@]
  756. _XSD_WAVTOP    dd 0 ; top of soundcard ram           [@]
  757.  
  758. _XSD_WAVCHAN   db 0 ; base channel for wavechannels if wavetable hardware [@]
  759. _XSD_WAVFLAGS  db 0 ; "custom" wavetable flags [@]
  760. _XSD_VOICES    db 0 ; "active" soundchannels (max 255) [*]
  761. _XSD_ROTCHAN   db 0 ; base index for autorotating soundchannels
  762.                     ; 0 <= _XSD_ROTCHAN <= _XSD_VOICES
  763. _XSD_CHANNEL dd _XSD_VOICES*32 ; soundchannel descriptors
  764. ; every descriptor uses 128 bytes
  765. softchan_size=128
  766. ; START OF SOUNDCHANNEL DESCRIPTOR
  767. wt_len=0     ; [D] LENGHT IN DWORDSof sound sample data TO PLAY [@]
  768. wt_ptr=4     ; [D] pointer to sound sample data TO PLAY [@]
  769. wt_sfeed=8   ; [D] sample data feeder
  770.              ; this is called with esi=ptr to soundchannel descriptor
  771.              ; and must SET INTO wt_len and wt_ptr
  772.              ; the lenght and pointer to the next sample to play
  773.              ; AND SET INTO wt_settings the required "sample info data"
  774.              ; about what's playing next
  775.              ; (bit8 =sample into soundcard ram
  776.              ;  bit9 =stereo sample
  777.              ;  bit10=delay)
  778.              ; to let the mixage system determine what to do.
  779.  
  780. wt_sdata=12  ; [D] "default sample" data    0 == silence, no output
  781.              ;      this is useful to play "background" sounds
  782.              ;      or to implement "sample looping" when playing
  783.              ;      instrument samples.
  784.              ;     The default feeder does not modify this entry
  785.              ;     once it has been set.
  786.  
  787. wt_ndata=16  ; [D] "next sample"    data    0 == use wt_sdata
  788.              ; the default feeder sets this entry to zero
  789.              ; once the referenced sample is "loaded to play"
  790.              ; into wt_len and wt_ptr descriptors.
  791.  
  792. ; SOUNDCHANNEL SETTINGS
  793. wt_settings=20 ; [D]
  794.                ; the "settings" entry is used as an index/reference to
  795.                ; show how this soundchannel is "set" and
  796.                ; to select the "internal feeder" routines needed to mix sound.
  797.                ;
  798.                ; Only EFFECTS with FLAG SET are supported, the others
  799.                ; are ignored.
  800. ; wt_settings flags
  801.                 ; user settable flags:
  802. sset_vctrl=1    ;volume settings
  803. sset_vramp=2    ;                           bit0 = volume control
  804. sset_pctrl=4    ;                           bit1 = volume control & ramps
  805. sset_pramp=8    ;                                  and call custom feeder
  806. sset_rctrl=16   ;                                  when ramp ends
  807. sset_rramp=32   ;
  808. sset_rotate=64  ;panning settings
  809. sset_active=128 ;                           bit2 = pan control
  810. sset_wavram=256 ;                           bit3 = pan control & ramps
  811. sset_stereo=512 ;                                  and call custom feeder
  812. sset_delay=1024 ;                                  when ramp ends
  813.                 ;
  814.                 ;rate settings
  815.                 ;                           bit4 = rate control
  816.                 ;                           bit5 = rate control & ramps
  817.                 ;                                  and call custom feeder
  818.                 ;                                  when ramp ends
  819.                 ;sound rotation/active channel
  820.                 ;                           bit6 = this is an autorotating
  821.                 ;                                  channel.
  822.                 ;                           bit7 = this is an active channel
  823.                 ;386mixer "private" flags
  824.                 ;sample location  [set by 386mixer, for internal usage]
  825.                 ;                           bit8 = sample into soundcard ram
  826.                 ;
  827.                 ;format settings  [set by 386mixer, for internal usage]
  828.                 ;                           bit9 = stereo sample
  829.                 ;                                  (no panning control)
  830.                 ;delayed launch   [set by 386mixer, for internal usage]
  831.                 ;                           bit10= delayed launch is pending:
  832.                 ;                                  wt_len is a "silence"
  833.                 ;                                  count (wt_ptr points to
  834.                 ;                                  4k "silence" buffer).
  835.                 ;                                  When count gets lower than
  836.                 ;                                  "feed buffer" size
  837.                 ;                                  start mixing the silence
  838.                 ;                                  track, then load
  839.                 ;                                  the wt_sdata sample
  840.                 ;                                  and set wt_sdata to zero.
  841.  
  842. ; voice mixage routines
  843. wt_mix_step1=24 ; data_feed/rate_convert/rate_ramp/mono_to_stereo
  844. wt_mix_step2=28 ; panning_control/panning_ramp
  845. wt_mix_step3=32 ; volume_control/volume_ramp
  846.  
  847.  
  848. ; custom feeders and data
  849. ; THESE ARE ALWAYS CALLED WHEN a "ramp" ends
  850. ; the default handlers are simple "do nothing& return" routines
  851. ; but if you stick here custom feeders you can do very complex thing
  852. wt_vfeed=36  ; [D] custom volume feeder
  853.              ;     called with esi=ptr to sounchannel descriptor
  854.              ;     must return into edx the "packed data" for the next
  855.              ;     volume ramp
  856. wt_vdata=40  ; [D] custom volume envelope data  0=nothing
  857.  
  858. wt_pfeed=44  ; [D] custom panning feeder
  859.              ;     called with esi=sounchannel descriptor
  860.              ;     must return into edx the "packed data" for the next
  861.              ;     panning ramp
  862. wt_pdata=48  ; [D] custom panning envelope data 0=nothing
  863. wt_rfeed=52  ; [D] custom rate feeder
  864.              ;     called with esi=sounchannel descriptor
  865.              ;     must return into edx,cx the "packed data" for the next
  866.              ;     rate ramp
  867. wt_rdata=56  ; [D] custom rate envelope data   0=nothing
  868.  
  869. ; "current values" and "ramp limit" data
  870. wt_vol=60     ; [W]  [@] volume in fixed point 8:8 format
  871. wt_volend=62  ; [W]  [@] ditto
  872. wt_pan=64     ; [W]  [@] panning in fixed point 8:8 format
  873. wt_panend=66  ; [W]  [@] ditto
  874. wt_rate=68    ; [W]  [@] current data rate ratio (relative to wavetable base
  875.               ;          frequency ( _XSD_WAVRATE)
  876.               ;          in fixed point 6:10 format (Gus format)
  877. wt_rateend=70 ; [W]  [@] ditto
  878.  
  879. ; "increment" values using the same format of current settings
  880. wt_volinc=72   ; [W] 8:8
  881. wt_paninc=74   ; [W] 8:8
  882. wt_rateinc=76  ; [W] 6:10
  883. wt_reserved1=78 ; [W]
  884. ; "width" of single ramp steps (in DWORDS of sample data)
  885. wt_volstep=80  ; [D]
  886. wt_panstep=84  ; [D]
  887. wt_ratestep=88 ; [D]
  888.  
  889. wt_reserved2=92 ; [D] "reserved" for future extension, this should be zero
  890.  
  891. wt_xswavd=96 ; [32 bytes] driver's private data
  892.              ; (from offset 96 included to offset 128 excluded)
  893.              ; THE DRIVER CAN USE THIS SPACE AS IT WANTS
  894.  
  895. ; END OF SOUNDCHANNEL DESCRIPTOR
  896.  
  897. _MixShutDown:   Shuts down mixer system (automatically called by _Exit)
  898.                 Calls the _XSD_OFF routine.
  899.  
  900.  
  901. _MixVolume: Master volume control
  902.             in: eax= volume:     0 = sound off
  903.                                255 = maximum output
  904.             Either a driver routine or a software emulated one
  905.             ALL THE OTHER VOLUME SETTING ARE RELATIVE TO THIS
  906.  
  907.             actual_voice_volume = (voice_volume/255)*master_volume
  908.  
  909. _MixFeeder: Set "mixer feeder" capabilities
  910.             in: eax= channel   (-1 = set on all channels)
  911.                 edx= new values for wt_settings (only bit0..bit7 are used)
  912.             This routine will set the "mix steps" entries according
  913.             to the driver settings and and the channel settings
  914.             (i.e. if there is a mono driver, panning is ignored).
  915.             N.B. You can read wt_settings DIRECTLY, but you can modify it
  916.                  only by way of _MixFeeder, because when you change
  917.                  the settings the mixer has to change
  918.                  some descriptor entries and other internal things
  919.  
  920.  
  921. _MixPlay: Play sound without sound effects
  922.           (use the default settings)
  923.           in: eax= channel   (-1 = autorotate to next "free" channel)
  924.               edx= sound handle  ( 0 = silence)
  925.  
  926. _MixFXPlay: Play sound with "sound effects".
  927.             eax= channel  (-1 = autorotate)
  928.             edx= sound handle
  929.             ecx= volstart(b),volstop(b),
  930.                  panstart(b),panstop(b) (dword packed)
  931.             ebx= voltime (w)(msec),
  932.                  pantime(w) (msec) (dword packed)
  933.                 ; the maximum "ramp" time for volume and panning
  934.                 ; is around 65 sec and the minimum is 1msec
  935.                 n.b. panning works only with stereo sound on
  936.             esi= ratestart (w), rateend (w)
  937.                    playback rate is given as a fixed point
  938.                    ratio 6:10 (6bit unsigned integer, 10bit mantissa)
  939.                    between "base rate" an "voice rate".
  940.              di= ratetime (msec)
  941.             ebp= sound start DELAY in dwords of silence sample data
  942.  
  943.            time: time for a COMPLETE ramp in milliseconds
  944.  
  945.            panning: 0=full left,  255=full right
  946.  
  947.            volume:  0=minimum,    255=maximum
  948.  
  949.            The DELAY parameter is a quite critical thing needed to implement
  950.            "live" echo effects and 3D sound.
  951.            It tells the mixer the exact number of DWORDS of silence data
  952.            that must be "played" BEFORE the actual sample starts.
  953.            So if is say 850 it means "perform equivalent action"
  954.            of playing a "silence" sample 850*4 bytes long.
  955.            Notice that changing the playback rate and the sample size
  956.            (8bit mono, 8bit stereo, 16bit mono, 16bit stereo)
  957.            the delay time changes, but it can be easily calculated
  958.            into lookup tables at program startup.
  959.            The actual "delay" time limits you can get ranges from
  960.            0.5 milliseconds to more than 65000 seconds.
  961.            The great advantage of delayed playback is that with it you can
  962.            "pack together" delayed sounds knowing that even on autorotating
  963.            softchannels the echo/3d_sound will hold at least until
  964.            something else "rotates over" some of the channels "playing together"
  965.            to produce the effect.
  966.  
  967.            N.B. Packing is in big endian order
  968.                 so ecx= volstart(b) ,volstop(b),panstart(b),panstop(b)
  969.                 means
  970.                      cl= volstart
  971.                      ch= volstop
  972.                      high word,low  byte = panstart
  973.                      high word,high byte = panstop
  974.  
  975. _SoundVolume: Set wavechannel volume
  976.               in:
  977.               eax= channel ( -1 = set volume of all autorotating channels)
  978.               edx= volstart (B),volend(B),voltime(W)
  979.               N.B.  volstart==volend
  980.                     or voltime== 0
  981.                     produces "constat" volume setting with volume=volend
  982.               (this function can be ignored by emulators if you want)
  983.  
  984. _SoundPanning: Set wavechannel panning
  985.                in:
  986.                eax= channel ( -1 = set volume of all autorotating channels)
  987.                edx= panstart (B),panend(B),pantime(W)
  988.                N.B. panstart==panend
  989.                     or pantime== 0
  990.                     produces "constat" volume setting with volume=volend
  991.                (this function can be ignored by emulators if you want)
  992.  
  993. _SoundRate: Set wavechannel playback rate  & disable rate ramp
  994.              in:
  995.              eax= channel ( -1 = set volume of all autorotating channels)
  996.              edx= ratestart(w),rateend(w)
  997.               cx= ratetime
  998.              N.B. ratestart==rateend
  999.                   or ratetime== 0
  1000.                   produces "constat" volume setting with volume=volend
  1001.              (this function can be ignored by emulators if you want)
  1002.  
  1003.  
  1004. As you can see these "default" effects are useful to emulate the
  1005. "basic hardware" on wavetable boards, they are NOT intended
  1006. to provide a full power "sound handling" system.
  1007. Effects such as echo, surround and others
  1008. can be "bolted on" later, using the appropriate feeders
  1009. depending where you think there is the maximum advantage.
  1010.  
  1011.  
  1012. _SndLoad: Loads a sound file (currently it can only be an 8bit mono VOC file
  1013.           but in a the next release it will cover more file formats)
  1014.  
  1015.           in: esi= pointer to file name string
  1016.               eax= destination
  1017.                    bit0: 0 = into ram.
  1018.                          1 = into wavetable ram if you can.
  1019.                    bit1: 0 = use it as a DAC sample
  1020.                              (convert it to the current DAC playback rate
  1021.                               and sample size)
  1022.                          1 = use it as a wavetable sample
  1023.                              (fill in the extra wavetable attributes)
  1024.               edi= pointer to start of sample header located into system ram
  1025.                    (even sounds with their samples located into wavetable ram
  1026.                     have their header located into system ram)
  1027.  
  1028.           out: if CARRY CLEAR then eax=sample handle (pointer to its header)
  1029.                                    check the sample header to see
  1030.                                    if the sound has been loaded into
  1031.                                    soundcard ram or not.
  1032.                                    edi=first free byte AFTER the sample
  1033.                                        header/data.
  1034.                if CARRY SET then error
  1035.                                    registers unchanged
  1036.  
  1037. ;SOUND SAMPLE (SMP) HEADER :
  1038. ; digital sound samples are handled
  1039. ; by way of headers that let the mixer code "detect"
  1040. ; the digital sound sample attributes.
  1041. ; The current header is 16 bytes long, but its size may change in future
  1042. ; releases of 386mixer, you CAN access the "already defined" entries
  1043. ; of a sound header, but don't assume anything about possible "new"
  1044. ; fields and flags. When the sound sample is into system ram
  1045. ; you can also copy the sample data and/or process it
  1046. ; In future releases i may add support for holographic/3dbinaural sound
  1047. ; (as soon as i get my hands on a cpu powerful enough and on
  1048. ;  documents giving me a decent audiomechanical model of the auditive system)
  1049. ; [ I know about the delayed sound reflection method and the
  1050. ;   phase difference to 3d position translation, what i still don't know
  1051. ;   are the exact parameters needed to process the delay+reflection
  1052. ;   (how many different delayed secondary waves? what's the law
  1053. ;    correlating direction and reflected wave scaling ?)
  1054. ; ]
  1055.  
  1056. smp_len=0    ; [D] lenght of sample in bytes
  1057. smp_datptr=4 ; [D] pointer to sample data
  1058. smp_type=8   ; [D] sample type flags (only bits 0..5 are currently defined)
  1059. smp_hlen=12  ; [D] size of header in bytes (must be dword aligned)
  1060. ; flags for sample type
  1061. smp_stereo=1    ; set=  this is a stereo sample, play it without applying
  1062.                 ;       panning or other effects except volume control
  1063.                 ;       (it contains precalculated sound effects)
  1064.                 ; else  mono sample, you can apply effects to it
  1065.                 ; N.B. the wavetable device CANNOT PLAY stereo samples!!!!
  1066.                 ;      (it can "play in stereo", but the "base sample"
  1067.                 ;       is a mono one!!)
  1068.  
  1069. smp_soundcard=2 ; set=  sample can be directly played by sound hardware
  1070.                 ; else  this is a sample completely stored into system ram
  1071.                 ;       and needs to be played on softchannels
  1072.  
  1073. smp_biport=4    ; set= soundcard ram is MAPPED INTO SYSTEM RAM
  1074.                 ;      so you can process samples like if they are
  1075.                 ;      on "plain" system ram AND play them
  1076.                 ;      on "hardware" directly
  1077.                 ; else soundcard ram is not directly accessible
  1078.                 ;      wt_len and wt_ptr contains values that are
  1079.                 ;      meaningful only for XSD the driver
  1080.  
  1081. smp_16bit=8     ; set = this is a 16bit sample
  1082.                 ; else  it is an 8bit sample
  1083.  
  1084. smp_signed=16   ; set = sound samples use a signed format
  1085.                 ; else  they use an unsigned format
  1086.  
  1087. smp_int=32      ; set = signed samples are like "ints"
  1088.                 ; else  signed samples use a "detached" sign bit
  1089.                 ;       (like in floating point numbers)
  1090.  
  1091.  
  1092.  
  1093. _Map2CPURam:     Maps to a buffer in system ram the sound/wave sample data
  1094.                  referenced by esi.
  1095.               in: esi =sound header
  1096.                   edi =pointer to buffer to use to store sound header
  1097.                        AND sound sample data immediately after
  1098.                        (but we don't know how wide is the header
  1099.                         so use the sound header fields to look where
  1100.                         the sound data is, or this could "break"
  1101.                         with future releases of 386mixer)
  1102.                   ebp = top of allocable ram in the heap pointed by edi
  1103.                         (this way we can avoid to run out of memory)
  1104.               out: if CARRY CLEAR then
  1105.                         esi=new sound header
  1106.                         edi=ptr to first free byte after sound data
  1107.                    else error, nothing has been changed
  1108.  
  1109.  
  1110. _Map2WAVRam:   Tries to "map into soundcard ram" the sound/wave sample
  1111.                referenced by esi.
  1112.                in: esi=sound header
  1113.                    edi=pointer to buffer for new sound header
  1114.                    ebp=top of allocable ram in the heap pointed by edi
  1115.                out:
  1116.                    if CARRY CLEAR then
  1117.                         esi=new handle.
  1118.                         edi=ptr to first free byte after sound data
  1119.                    else error, nothing has been changed
  1120.  
  1121. _WRClear:  resets all the sound card ram
  1122.  
  1123. _WRAMMark: marks the allocate memory into wavetable ram
  1124.            out: eax=mark handle
  1125.  
  1126. _WRAMRelease: releases the allocated memory into wavetable ram
  1127.               in: eax=mark handle
  1128.  
  1129. _MixSyncSound:   Call this when you have to "play together" multiple sounds
  1130.                  so they will start AFTER the mixer has been "unsynched"
  1131.  
  1132. _MixUnSyncSound:  Mixer system back to "normal" mode, all synched channels
  1133.                   will start playing from here.
  1134.                   It is assumed you will "sync"-->"unsync" the mixer
  1135.                   faster than the feed rate (or "feed noise" will happen)
  1136.  
  1137.  
  1138.